function RobotController(
    initialList,//路由中预加载数据的注入
    $scope,
    $rootScope,
    Robot,
    $uibModal,
    $state,
    $stateParams
) {
    var vm = this;
    vm.resultMsg;
    vm.scope = $rootScope.$new();



    initialList.$promise.then(function(response) {
        var rusersesultObj = response.page;
        vm.robots=rusersesultObj.content;
        vm.isLoaded = true;
        vm.queryParams = _.clone($stateParams)
        vm.totalItems = rusersesultObj.totalElements
        vm.totalPages = rusersesultObj.totalPages
    })

    vm.delete = function(robot) {
        var keepGoing = false;
        var modalInstance = $uibModal.open({
            templateUrl: 'myModalContent.html',
            controller: 'ModalInstanceCtrl',
            size: robot
        });

        // 模拟窗口关闭后回传调用
        modalInstance.result.then(function (selectedItem) {
            if(selectedItem == 'ok') {
                Robot.delete({
                    robotNumber : robot.id
                }).$promise.then(function(response){
                    if(response.result == "0"){
                        vm.resultMsg = "删除失败，请稍后再试！";
                        keepGoing = true;
                    }else if(response.result == "err"){
                        vm.resultMsg = "删除失败，"+response.msg+"！";
                        keepGoing = true;
                    }
                    if(keepGoing){
                        vm.scope.data = {
                            msg:vm.resultMsg
                        }
                        var tipsModel = $uibModal.open({
                            templateUrl: 'tipsModel.html',
                            controller: 'robotTipsCtrl',
                            scope:vm.scope
                        });
                    }else{
                        $state.reload($state.current)
                    }
                })
            }
        });
    }

    vm.reset = function(parameter) { vm.queryParams = {}; }

    vm.search = function() { $state.go($state.current, vm.queryParams) }

    vm.robotAddInGroup = function(robot) { $state.go("robotChooseGroup", {robotId:robot.id}) };

}

